# TRIGGER_SPLITTER
DROP TRIGGER IF EXISTS  `pk_shop_config_log` ;   
# TRIGGER_SPLITTER    
DROP TRIGGER IF EXISTS  `pk_pack_log`;
# TRIGGER_SPLITTER               
DROP TRIGGER IF EXISTS  `pk_group_pro_gallery_log` ; 
# TRIGGER_SPLITTER
DROP TRIGGER IF EXISTS  `pk_goods_log`;           
# TRIGGER_SPLITTER   
DROP TRIGGER IF EXISTS  `pk_goods_gallery_log`;   
# TRIGGER_SPLITTER   
DROP TRIGGER IF EXISTS  `pk_friend_link_log`; 
# TRIGGER_SPLITTER       
DROP TRIGGER IF EXISTS  `pk_color_lib_log` ; 
# TRIGGER_SPLITTER        
DROP TRIGGER IF EXISTS  `pk_color_log` ;   
# TRIGGER_SPLITTER          
DROP TRIGGER IF EXISTS  `pk_card_log`;
# TRIGGER_SPLITTER              
DROP TRIGGER IF EXISTS  `pk_buyershow_log`; 
# TRIGGER_SPLITTER         
DROP TRIGGER IF EXISTS  `pk_brand_log` ;    
# TRIGGER_SPLITTER         
DROP TRIGGER IF EXISTS  `pk_article_log`;  
# TRIGGER_SPLITTER          
DROP TRIGGER IF EXISTS  `pk_dynamic_log`;  

# TRIGGER_SPLITTER
CREATE   TRIGGER  `pk_shop_config_log` AFTER INSERT ON  `open_shop_config`
  FOR EACH ROW BEGIN

dECLARE pkf varchar(50) DEFAULT "";

sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="shop_config";

if pkf <> "shop_config" then

  INSERT INTO open_pk_log SET pk_from = 'shop_config', pk_id = NEW.id;

eLSE

   update open_pk_log SET pk_id = NEW.id WHERE pk_from = 'shop_config';

end if;

end;

# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_pack_log` AFTER INSERT ON `open_pack`
  FOR EACH ROW BEGIN
DECLARE pkf varchar(50) DEFAULT "";
SELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="pack";
if pkf <> "pack" then
  INSERT INTO open_pk_log SET pk_from = 'pack', pk_id = NEW.pack_id;
eLSE
   update open_pk_log SET pk_id = NEW.pack_id WHERE pk_from = 'pack';
end if;
end;

# TRIGGER_SPLITTER
CREATE   TRIGGER `pk_group_pro_gallery_log` AFTER INSERT ON `open_group_promotion_gallery`
  FOR EACH ROW BEGIN
DECLARE pkf varchar(50) DEFAULT "";
SELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="group_pro_gallery";
if pkf <> "group_pro_gallery" then
  INSERT INTO open_pk_log SET pk_from = 'group_pro_gallery', pk_id = NEW.img_id;
eLSE
   update open_pk_log SET pk_id = NEW.img_id WHERE pk_from = 'group_pro_gallery';
end if;
end;

# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_goods_log` AFTER INSERT ON `open_goods`
  FOR EACH ROW BEGIN
DECLARE pkf varchar(50) DEFAULT "";
SELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="goods";
if pkf <> "goods" then
   INSERT INTO open_pk_log SET pk_from = 'goods', pk_id = NEW.goods_id;
ELSE
    update open_pk_log SET pk_id = NEW.goods_id WHERE pk_from = 'goods';
end if;
END;


# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_goods_gallery_log` AFTER INSERT ON `open_goods_gallery`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="goods_gallery";
if pkf <> "goods_gallery" then
  INSERT INTO open_pk_log SET pk_from = 'goods_gallery', pk_id = NEW.img_id;
eLSE
   update open_pk_log SET pk_id = NEW.img_id WHERE pk_from = 'goods_gallery';
end if;
end;


# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_friend_link_log` AFTER INSERT ON `open_friend_link`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="friend_link";
if pkf <> "friend_link" then
  INSERT INTO open_pk_log SET pk_from = 'friend_link', pk_id = NEW.link_id;
eLSE
   update open_pk_log SET pk_id = NEW.link_id WHERE pk_from = 'friend_link';
end if;
end;

# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_color_lib_log` AFTER INSERT ON `open_color_lib`
  FOR EACH ROW BEGIN
 dECLARE pkf varchar(50) DEFAULT "";
 sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="color_lib";
 if pkf <> "color_lib" then
   INSERT INTO open_pk_log SET pk_from = 'color_lib', pk_id = NEW.img_id;
 eLSE
    update open_pk_log SET pk_id = NEW.img_id WHERE pk_from = 'color_lib';
 end if;
 end;


# TRIGGER_SPLITTER 
CREATE  TRIGGER `pk_color_log` AFTER INSERT ON `open_color`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="color";
if pkf <> "color" then
  INSERT INTO open_pk_log SET pk_from = 'color', pk_id = NEW.color_id;
eLSE
   update open_pk_log SET pk_id = NEW.color_id WHERE pk_from = 'color';
end if;
end;

# TRIGGER_SPLITTER 
CREATE  TRIGGER `pk_card_log` AFTER INSERT ON `open_card`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="card";
if pkf <> "card" then
  INSERT INTO open_pk_log SET pk_from = 'card', pk_id = NEW.card_id;
eLSE
   update open_pk_log SET pk_id = NEW.card_id WHERE pk_from = 'card';
end if;
end;


# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_buyershow_log` AFTER INSERT ON `open_buyer_show`
  FOR EACH ROW BEGIN

DECLARE pkf varchar(50) DEFAULT "";

SELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="buyer_show";

if pkf <> "buyer_show" then

   INSERT INTO open_pk_log SET pk_from = 'buyer_show', pk_id = NEW.id;

ELSE

    update open_pk_log SET pk_id = NEW.id WHERE pk_from = 'buyer_show';

end if;

END;

# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_brand_log` AFTER INSERT ON `open_brand`
  FOR EACH ROW BEGIN
DECLARE pkf varchar(50) DEFAULT "";
SELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="brand";
if pkf <> "brand" then
   INSERT INTO open_pk_log SET pk_from = 'brand', pk_id = NEW.brand_id;
ELSE
    update open_pk_log SET pk_id = NEW.brand_id WHERE pk_from = 'brand';
end if;
END;

# TRIGGER_SPLITTER
CREATE  TRIGGER `pk_article_log` AFTER INSERT ON `open_article`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="article";
if pkf <> "article" then
  INSERT INTO open_pk_log SET pk_from = 'article', pk_id = NEW.article_id;
eLSE
   update open_pk_log SET pk_id = NEW.article_id WHERE pk_from = 'article';
end if;
end;

# TRIGGER_SPLITTER
CREATE   TRIGGER  `pk_dynamic_log` AFTER INSERT ON  `open_dynamic`
  FOR EACH ROW BEGIN 

dECLARE pkf varchar(50) DEFAULT "";

sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="dynamic";

if pkf <> "dynamic" then

  INSERT INTO open_pk_log SET pk_from = 'dynamic', pk_id = NEW.dy_id;

eLSE

   update open_pk_log SET pk_id = NEW.dy_id WHERE pk_from = 'dynamic';

end if;

end;